package com.yanqingying.controller;
import com.yanqingying.aop.log;
import com.yanqingying.Clazz;
import com.yanqingying.ClazzQueryParam;
import com.yanqingying.PageBean;
import com.yanqingying.Result;
import com.yanqingying.service.impl.ClazzServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/clazzs")
@RestController
public class ClazzController {
    @Autowired
    ClazzServiceImpl clazzService;

    @GetMapping()
    public Result getPage(ClazzQueryParam clazz) {
        PageBean pageBean = clazzService.getPage(clazz);
        return Result.success(pageBean);
    }
    @log
    @DeleteMapping("/{id}")
    public Result dele(@PathVariable Integer id) {
        clazzService.dele(id);
        return Result.success();
    }
    @log
    @PostMapping
    public Result insert(@RequestBody Clazz clazz) {
        clazzService.insert(clazz);
        return Result.success();

    }

    @GetMapping("/{id}")
    public Result geta(@PathVariable Integer id) {
        Clazz geta = clazzService.geta(id);
        return Result.success(geta);
    }
    @log
    @PutMapping
    public Result upDate(@RequestBody Clazz clazz) {
        clazzService.upDate(clazz);
        return Result.success();
    }

    @GetMapping("/list")
    public Result lists(Integer ids){
        clazzService.getList(ids);
        return Result.success();

    }
}
